package com.zprmb.udzt;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zprmb.udzt.fragment.PagerSlidingTabStrip;
import com.zprmb.udzt.fragment.Regular_fragment;
import com.zprmb.udzt.view.DepthPageTransformer;

public class Regular_money extends BaseActivity implements OnClickListener{
	private PagerSlidingTabStrip tabs;
	private ViewPager pager;
	private MyPagerAdapter adapter;
	private int currentColor = R.color.bbt_main_down;
	private TextView tv_title_context;
	private ImageView img_back;
	private RelativeLayout rl_back;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.regular_money);
		 BbtApplication.getInstance().addActvity(this);
		initView();
	}
	private void initView() {
		tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
		img_back=(ImageView)findViewById(R.id.img_back);
		img_back.setOnClickListener(this);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		rl_back.setOnClickListener(this);
		pager = (ViewPager) findViewById(R.id.pager);
		adapter = new MyPagerAdapter(getSupportFragmentManager());
		pager.setOffscreenPageLimit(2);
		pager.setAdapter(adapter);
		final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources()
				.getDisplayMetrics());
		pager.setPageMargin(pageMargin);
		tabs.setViewPager(pager);
		tabs.setUnderlineHeight(0);
		pager.setPageTransformer(true, new DepthPageTransformer());
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
	public class MyPagerAdapter extends FragmentPagerAdapter {

		private final String[] TITLES = {"理财中","已回款"};
		

		public MyPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		public CharSequence getPageTitle(int position) {
			return TITLES[position];
		}

		public int getCount() {
			return TITLES.length;
		}

		public Fragment getItem(int position) {
			
				return Regular_fragment.newInstance(position,TITLES[position],getToken());
			
		}
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.img_back:
			finish();
			break;
		case R.id.rl_back:
			finish();
			break;
		}
		
	}

}
